function render(list) {
  let oAlbumList = document.querySelector('.albumList')
  for (let i in list) {
    let album = list[i]

    let html = `    <div class="album">
      <div class="cover-wrapper">
        <a href="/play.html?aid=${album.aid}"><img class="cover" src="${album.cover}"></a>
      </div>        
      <div class="title"><a href="/play.html?aid=${album.aid}">${album.title}</a></div>
      <div class="author">${album.username}</div>
    </div>`

    oAlbumList.innerHTML += html
  }
}

window.addEventListener('load', function () {
  let xhr = new XMLHttpRequest()
  xhr.open('get', '/album-list.json')
  xhr.addEventListener('load', function () {
    console.log(this.responseText)
    let data = JSON.parse(this.responseText)
    render(data.albumList)
  })
  xhr.send()
})